
$(function () {
    let $File = $('.files');

    console.log(File);

    $File.change(function () {
        let file = this.files[0];
        // let file = this.files;
        console.log(file);
        let oFormData = new FormData();
        oFormData.append('image_url',file);
        console.log(oFormData);

        $.ajax({
            url: '/up/',
            method: 'POST',
            data: oFormData,
            processData: false,
            contentType: false,

            success:function (res) {
                if (res['image_url']){
                    // alert('图片上传成功！')
                    let img_url = res['image_url']
                    $('.img-rounded').attr('src',img_url)
                    $('#image_url').attr('value',img_url)
                }else {
                    alert('图片上传失败！')
                }
            }
        })
    });
});